﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;

public partial class Crm_CreateHtml : System.Web.UI.Page
{
    List<Dukey.Model.Boards> listb = BLL.Boards.instance.GetList("isshow=True and ismain=True");
    List<Dukey.Model.Articles> listArticle = BLL.Articles.instance.GetListByCache("");
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        foreach (var item in listb)
        {
            if (item.linkto != null)
            {
                string filepath = "~/html/" + item.linktohtml;
                Response.Redirect(item.linkto + "&" + filepath);
                ClientScript.RegisterClientScriptBlock(this.GetType(), "success", "<script>$.Chtml('" + item.linkto + "&" + filepath + "');</script>");
            }
        }

        //CreateHtmlPage("/show.ashx", Server.MapPath("~/html/index.html"));
    }

    #region 生成静态页面
    /// <summary>
    /// 生成静态页面
    /// </summary>
    /// <param name="sourcePath">需要生成的页面</param>
    /// <param name="saveHtmlPath">生成后的静态页面</param>
    /// <returns></returns>
    public bool CreateHtmlPage(string sourcePath, string saveHtmlPath)
    {
        StreamWriter sw = null;
        try
        {
            sw = new StreamWriter(saveHtmlPath, false, Encoding.GetEncoding("utf-8"));
            Server.Execute(sourcePath, sw);
            sw.Close();
        }
        catch (Exception ex)
        {
            System.Web.HttpContext.Current.Response.Write(ex.ToString());
            sw.Close();
            Response.End();
        }
        return true;
    }
    #endregion

   

    protected void btnCreateArticles_Click(object sender, EventArgs e)//生成文章
    {

    }
}
